#define  _CRT_SECURE_NO_WARNINGS

#include "sort.h"

int cmp_struct_name(const void* a, const void* b)
{
	return strcmp(((struct people*)a)->name, ((struct people*)b)->name);
}

void text()
{
	struct people p[] = { {"xiaoshuai",24,73.4 },{"xiaomei",25,57.3},{"xiaochou",26,67.2} };
	int sz = sizeof(p) / sizeof(p[0]);
	bubble_sort(p, sz, sizeof(p[0]), cmp_struct_name);
	print_struct_name(p, sz);
}

int cmp_struct_age(const void* a, const void* b)
{
	int arg1 = *(int*)a;
	int arg2 = *(int*)b;
	return (arg1 > arg2) - (arg1 < arg2);
}

void text1()
{
	struct people p[] = { {"xiaoshuai",24,73.4 },{"xiaomei",25,57.3},{"xiaochou",26,67.2} };
	int sz = sizeof(p) / sizeof(p[0]);
	bubble_sort(p, sz, sizeof(p[0]), cmp_struct_age);
	print_struct_age(p, sz);
}

int main()
{
	text();
	//text1();
	return 0;
}